function resOut = runHamiltonFilter(data)
% For quarterly data using p = 4 and h = 8 
p = 4;
h = 8;

Y  = data(p+h+1:end,1);
X3 = data(1:end-p-h);
X2 = data(2:end-p-h+1);
X1 = data(3:end-p-h+2);
X0 = data(4:end-p-h+3);
numObs = length(Y);
X = [ones(numObs,1) X0 X1 X2 X3];
betaHat = (X'*X)\(X'*Y);
res = Y-X*betaHat;
resOut = [NaN(p+h,1);res];


end